{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>签到日志列表</legend>
    </fieldset>
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="{if $flag1==1}layui-this{/if}">考勤日报</li>
            <li class="{if $flag2==2}layui-this{/if}"><a href="{:url('monthList')}">考勤月报</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show" style="float: left">
                <form class="layui-form" action="">
                    <div style="float:left;margin-left:-119px">
                        <div class="layui-form-item">
                            <div class="layui-input-block" style="width: 500px;">
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" id="time" placeholder="开始时间">
                                        <input type="text" class="layui-input" id="time1" placeholder="结束时间" style="margin-left: 196px;margin-top: -37px;">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div style="float:left;">
                        <div class="layui-form-item" style="    margin-left: -217px;margin-top: 1px;">
                            <div class="layui-input-block" style="width: 210px;">
                                <select  class="form-control input-sm" name="status" lay-filter="status" aria-invalid="false" id="status1">
                                    <option value="0" disabled selected style="display:none">请选择打卡状态(默认全部)</option>
                                    <option value="1">正常</option>
                                    <option value="2">请假</option>
                                    <option value="4">迟到</option>
                                    <option value="5">出差</option>
                                    <option value="6">旷工</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div style="float:left;">
                        <div class="layui-form-item" style="    margin-left: -103px;margin-top: -2px;">
                            <div class="layui-input-block" style="width: 500px;">
                                <div class="layui-inline" >
                                    <div class="layui-input-inline" style="width: 200px;">
                                        <input type="text" id="keyword" name="keyword" autocomplete="off" placeholder="请输入教师姓名/教师编号" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline" style="margin-right: 6px;">
                                    <div class="layui-btn-group layui-inline">
                                        <a  href="{:url('dayList')}" class="layui-btn layui-btn-primary">重置</a>
                                        <button id="search" class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="formDemo" style="background-color: #009688;">
                                            <i class="layui-icon">&#xe615;</i>查找
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>

                </form>
            </div>
            <button id="timing" class="layui-btn layui-btn-normal" type="button" style="background-color: #009688;float: right">
                同步数据
            </button>
        </div>
    </div>
    <table class="layui-table" id="list1" lay-filter="list1"></table>
</div>
</div>

{include file="common/foot"/}

<script type="text/html" id="status">
    {{# if(d.status=='1'){ }}
    &nbsp; &nbsp; &nbsp; &nbsp;√
    {{# }else if(d.status=='2'){ }}
    {{# }else if(d.status=='4'){ }}
    {{# }else if(d.status=='5'){ }}
    {{# }else if(d.status=='6'){ }}
    {{# }else { }}
    待定
    {{# } }}
</script>

<script type="text/html" id="leave_day">
    {{# if(d.status=='2'){ }}
    &nbsp; &nbsp; &nbsp; &nbsp;√
    {{# }else { }}
    {{# } }}
</script>
<script type="text/html" id="late">
    {{# if(d.status=='4'){ }}
    20分钟
    {{# }else { }}
    {{# } }}
</script>
<script type="text/html" id="business_trip_day">
    {{# if(d.status=='5'){ }}
    &nbsp; &nbsp; &nbsp; &nbsp; √
    {{# }else { }}
    {{# } }}
</script>
<script type="text/html" id="absent_day">
    {{# if(d.status=='6'){ }}
    &nbsp; &nbsp; &nbsp; &nbsp;√
    {{# }else { }}
    {{# } }}
</script>

<script>
    layui.use(['table','element','laydate','form'], function() {
        var table = layui.table, form = layui.form, $ = layui.jquery,laydate = layui.laydate;

        var tableIn = table.render({
            id: 'user',
            elem: '#list1',
            url: "{:url('dayList')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {field: 'teacher_no',title: '教师工号', width: 150},
                {field: 'true_name', title: '教师姓名', width: 150},
                {field: 'title', title: '所在部门', width: 100},
                {field: 'rule_name', title: '考勤规则', width: 150},
                {field: 'sign_time', title: '签到时间', width: 200},
                {field: 'status',title: '正常签到', width: 120,templet:'#status'},
                {field: 'late_time',title: '迟到', width: 120,templet:'#late'},
                {field: 'status',title: '请假', width: 100,templet:'#leave_day'},
                {field: 'status',title: '出差', width: 100,templet:'#business_trip_day'},
                {field: 'status',title: '旷工', width: 100,templet:'#absent_day'},
                {field: 'content',title: '备注', width: 200},
            ]],
            limit: 10 //每页默认显示的数量
        });

        $('#search').on('click', function () {
            // 关键字
            var keyword = $('#keyword').val();
            // 开始时间
            var time = $('#time').val();
            // 结束时间
            var time1 = $('#time1').val();
            // 状态
            var status1 = $('#status1').val();

            if(time1!=''&&time==''){
                layer.msg('请选择起始时间！', {icon: 0});
                return;
            }

            if (time>time1){
                layer.msg('起始时间应小于结束时间！', {icon: 0});
                return;
            }


            if (($.trim(keyword) === '') && ($.trim(status1) == 0) && ($.trim(time) === '') && ($.trim(time1) === '')) {
                layer.msg('请选择查找条件！', {icon: 0});
                return;
            }

            //表格重载
            tableIn.reload({
                //传递额外参数
                where: {keyword: keyword,start_time:time,end_time:time1,status:status1}
            });
        });
        //年月选择器
        laydate.render({
            elem: '#time'
            ,format: 'yyyy-MM-dd'
        });
        //年月选择器
        laydate.render({
            elem: '#time1'
            ,format: 'yyyy-MM-dd'
        });

        var status = 0;
        var statusName = '';
        form.on('select(status)', function (data) {
            status = data.value;
            statusName = data.elem[data.elem.selectedIndex].text;
            form.render('select');
            var keyword1 = status;
            if ($.trim(keyword1) === '') {
                layer.msg('{:lang("pleaseEnter")}查找信息！', {icon: 0});
                return;
            }
        });

        $('#timing').on('click', function () {
            var myDate = new Date();
            var h=myDate.getHours();
            if (h<=12){
                url = "{:url('am_timing')}";
            }else {
                url = "{:url('pm_timing')}";
            }
            layer.msg('同步中',{icon:16,shade:0.01});
            $.post(url,"",function (res) {
                if(res.code){
                    layer.closeAll();
                    //表格重载
                    tableIn.reload({
                    });
                }else{
                    layer.msg(res.msg, {icon: 2});
                }
            });
        });

    });
</script>
</body>
</html>